package com.tanhua.server.controller;

import com.tanhua.model.Voice;
import com.tanhua.server.service.PeachblossomService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

@RestController
@RequestMapping("/peachblossom")
public class peachblossomController {

    @Autowired
    private PeachblossomService peachblossomService;

    //桃花传音发送
    @PostMapping
    public ResponseEntity peachblossom(MultipartFile soundFile) throws IOException {
        peachblossomService.peachblossom(soundFile);
        return ResponseEntity.ok(null);
    }

    //桃花传音接受
    @GetMapping
    public ResponseEntity peachblossomGet(MultipartFile soundFile) throws IOException {
        Voice voice = peachblossomService.peachblossomGet();
        return ResponseEntity.ok(voice);
    }
}
